package com.ruoyi.secondvitim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.secondvitim.domain.VitimNurse;
import com.ruoyi.secondvitim.service.IVitimNurseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 护士列表Controller
 * 
 * @author alonso_ecit
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/secondVitim/nurse")
public class VitimNurseController extends BaseController
{
    @Autowired
    private IVitimNurseService vitimNurseService;

    /**
     * 查询护士列表列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:list')")
    @GetMapping("/list")
    public TableDataInfo list(VitimNurse vitimNurse)
    {
        startPage();
        List<VitimNurse> list = vitimNurseService.selectVitimNurseList(vitimNurse);
        return getDataTable(list);
    }

    /**
     * 导出护士列表列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:export')")
    @Log(title = "护士列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VitimNurse vitimNurse)
    {
        List<VitimNurse> list = vitimNurseService.selectVitimNurseList(vitimNurse);
        ExcelUtil<VitimNurse> util = new ExcelUtil<VitimNurse>(VitimNurse.class);
        util.exportExcel(response, list, "护士列表数据");
    }

    /**
     * 获取护士列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:query')")
    @GetMapping(value = "/{nurseNo}")
    public AjaxResult getInfo(@PathVariable("nurseNo") String nurseNo)
    {
        return success(vitimNurseService.selectVitimNurseByNurseNo(nurseNo));
    }

    /**
     * 新增护士列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:add')")
    @Log(title = "护士列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VitimNurse vitimNurse)
    {
        return toAjax(vitimNurseService.insertVitimNurse(vitimNurse));
    }

    /**
     * 修改护士列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:edit')")
    @Log(title = "护士列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VitimNurse vitimNurse)
    {
        return toAjax(vitimNurseService.updateVitimNurse(vitimNurse));
    }

    /**
     * 删除护士列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:nurse:remove')")
    @Log(title = "护士列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nurseNos}")
    public AjaxResult remove(@PathVariable String[] nurseNos)
    {
        return toAjax(vitimNurseService.deleteVitimNurseByNurseNos(nurseNos));
    }
}
